package com.letoken.platform.app.sss.controller;


import com.letoken.platform.pub.annotation.auth.NotAuthorization;
import com.letoken.platform.pub.res.ApiResponse;
import com.letoken.platform.repo.app.req.user.AppUserSwapProportionReq;
import com.letoken.platform.repo.sss.req.ForgetPasswordReq;
import com.letoken.platform.repo.sss.req.LoginReq;
import com.letoken.platform.repo.sss.req.RegisterReq;
import com.letoken.platform.repo.sss.servie.AppUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import software.amazon.awssdk.services.sqs.endpoints.internal.Value;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 作者
 * @since 2024-09-05
 */
@RestController
@RequestMapping("/appUserInfo")
@Api(tags = "用户相关接口", description = "用户相关接口")
public class AppUserInfoController {
    @Autowired
    private AppUserInfoService appUserInfoService;
    @PostMapping("/register")
    @NotAuthorization
    @ApiOperation(value = "注册", notes = "注册")
    public ApiResponse register(@RequestBody @Validated RegisterReq req) {
        appUserInfoService.register(req);
        return ApiResponse.create();
    }

    @PostMapping("/login")
    @NotAuthorization
    @ApiOperation(value = "登陆", notes = "登陆 返回token字符串")
    public ApiResponse<String> login(@RequestBody @Validated LoginReq req) {
        return ApiResponse.create(appUserInfoService.login(req));
    }

    @PostMapping("/forgetPassword")
    @NotAuthorization
    @ApiOperation(value = "找回密码", notes = "找回密码")
    public ApiResponse forgetPassword(@RequestBody @Validated ForgetPasswordReq req) {
        appUserInfoService.forgetPassword(req);
        return ApiResponse.create();
    }

}

